home *** CD-ROM | disk | FTP | other *** search
/ NeXT Education Software Sampler 1992 Fall / NeXT Education Software Sampler 1992 Fall.iso / Programming / Source / HippoDraw / HippoDrawSrc1.1 / Hippo.subproj / Tiff.m < prev   
Encoding:
Text File  |  1992-04-25  |  1.0 KB  |  41 lines

  1. #import "Tiff.h"
  2. #import "Image.h"
  3. #import <appkit/nextstd.h>
  4. #import <appkit/tiff.h>
  5.  
  6. @implementation Tiff
  7.  
  8. - replaceWithImage
  9. {
  10.     id retval = [[Image allocFromZone:[self zone]] initFromStream:newStream allowAlpha:NO];
  11.     [retval setBounds:&bounds];
  12.     if (!gFlags.selected) [retval deselect];
  13.     if (gFlags.locked) [retval lock];
  14.     [self free];
  15.     return retval;    
  16. }
  17.  
  18. - read:(NXTypedStream *)stream
  19. {
  20.     int length;
  21.     char *data;
  22.     NXImageInfo info;
  23.  
  24.     [super read:stream];
  25.     NXReadTypes(stream, "iiiiii", &info.width, &info.height,
  26.     &info.bitsPerSample, &info.samplesPerPixel,
  27.     &info.planarConfig, &info.photoInterp);
  28.     length = info.height * (info.samplesPerPixel) * ((info.bitsPerSample * info.width + 7) / 8);
  29.     NX_ZONEMALLOC([self zone], data, char, length+1);
  30.     NXReadArray(stream, "c", length, data);
  31.     data[length] = '\0';
  32.     newStream = NXOpenMemory(NULL, 0, NX_READWRITE);
  33.     NXWriteTIFF(newStream, &info, data);
  34.     NXSeek(newStream, 0, NX_FROMSTART);
  35.     NX_FREE(data);
  36.  
  37.     return self;
  38. }
  39.  
  40. @end
  41.